import MaskItem from "../../item/Common/MaskItem";
import LvItem_18 from "./LvItem_18";

const { ccclass, property } = cc._decorator;

@ccclass
export default class GuaItem extends cc.Component {


    // LIFE-CYCLE CALLBACKS:

    // onLoad () {}
    isClick: boolean = true;
    start() {
        this.node.on(cc.Node.EventType.TOUCH_MOVE, this.touchMoveBack, this);
        this.node.on(cc.Node.EventType.TOUCH_START, this.touchStart, this);
        this.node.on(cc.Node.EventType.TOUCH_END, this.touchEnd, this);
    }
    protected onDestroy(): void {
        this.node.off(cc.Node.EventType.TOUCH_MOVE, this.touchMoveBack, this);
        this.node.off(cc.Node.EventType.TOUCH_START, this.touchStart, this);
        this.node.off(cc.Node.EventType.TOUCH_END, this.touchEnd, this); 
    }


    touchStart() {
    }

    touchEnd() {
    }

    touchMoveBack(touches: cc.Event.EventTouch) {
        if (!this.isClick) {
            return
        }
        let maskItem: MaskItem = this.node.getComponent("MaskItem");
        maskItem.updateRubOut(touches.getLocation());
        if (maskItem.isWinRub) {
            maskItem.rubNode.active = false;
            this.isClick = false;
            // this.node.active=false;
            // EventManager.ins.emit(EVENT_NAME_ENUM.FINISH_INTER_TWEEN,);
            this.node.getComponent(LvItem_18).isClick = true;
        }
    }
    // update (dt) {}
}
